﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>WebFormMVC测试系统V1.0-登录</title>
    <link href="/View/css/login.css" rel="stylesheet" />
</head>
<body class="login">
    <div id="wrapper">
        <div id="content">
            <div id="header">
                <h1 style="color: white; margin-top: 8px; text-align: center;">WebFormMVC测试系统V1.0</h1>
            </div>
            <div id="darkbanner" class="banner320">
                <h2>用户登录 | USER LOGIN</h2>
            </div>
            <div id="darkbannerwrap"></div>
            <fieldset class="form">
                <p>
                    <label class="loginlabel" for="user_name">帐号:</label>
                    <input
                        class="logininput ui-widget-content" name="loginId" id="user_name"
                        type="text" value="admin" />
                </p>
                <p>
                    <label class="loginlabel" for="user_password">密码:</label>
                    <span>
                        <input class="logininput ui-widget-content" name="loginPwd"
                            id="user_password" type="password" value="123456" />
                    </span>
                </p>
                <div id="errmsg"></div>
                <div>
                    <button id="loginbtn" type="button" class="positive" name="Submit">
                        <img src="/View/images/key.png" />快速登录
                    </button>
                </div>
                <p style="margin-top:16px">默认用户名admin,密码123456</p>
            </fieldset>
        </div>
    </div>

    <script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript">
        // 禁止登录页内嵌
        if (window != top) {
            parent.location.href = location.href;
        }

        $(function () {
            $('form :input:first').focus();
            $('form :input').keyup(function (event) {
                if (event.keyCode == 13) {
                    $('#loginForm').submit();
                }
            });
        });
        $(document).ready(function () {
            $(".logininput").blur(function () {
                if ($(this).val() == "") {
                    $(this).css("border-color", "red");
                } else {
                    $(this).css("border-color", "#D9D6C4");
                }
            })

            $("#loginbtn").click(function () {
                var k = 0;
                $(".logininput").each(function (i, obj) {
                    if ($(obj).val().trim() == "") {
                        k++;
                        $(this).css("border-color", "red");
                        $(this).focus();
                    }
                });
                if (k != 0)
                    return false;
                $.ajax({
                    type: "GET",
                    url: "/user/toLogin",
                    data: {
                        username: $("#user_name").val(),
                        pwd: $("#user_password").val()
                    },
                    dataType: "json",
                    beforeSend: function () {
                        $("#loginbtn").html("Loading....");
                        $("#loginbtn").attr("disabled", "disabled");
                    },
                    success: function (data) {
                        if (data.success)
                            window.location.href = data.url;
                        else {
                            $("#loginbtn").html("快速登录");
                            $("#loginbtn").removeAttr("disabled");
                            $('#errmsg').text(data.errmsg);
                        }
                    }
                });
            })
        });
    </script>
</body>
</html>
